<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>判读选择器是否选择成功</title>
	<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
	<script type="text/javascript">
		$(function(){

			// 用length（>0）属性来判断是否选中了元素

			var $div = $('#div1');
			var $span = $('#span1');


			alert($div.length);

			alert($span.length);


		})

	</script>
</head>
<body>
	<div id="div1">这是一个div元素</div>
</body>
</html>